<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台用户管理</title>
    <link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="/static/assets/module/admin.css?v=318"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<style>
    .css_red{
        color: red;
    }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 表格工具栏 -->
            <form class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">手机号码:</label>
                        <div class="layui-input-inline">
                            <input name="username" class="layui-input" placeholder="输入手机号码"/>
                        </div>
                    </div>
                     <label class="layui-form-label">状态:</label>
                        <div class="layui-input-inline">

                            <select name="flag" lay-verType="tips" >
                                <option value="">选择</option>
                                <option value="0">待处理</option>
                                <option value="1">已打款</option>
                                <option value="2">审核失败</option>
                            </select>
                        </div>

                    <div class="layui-inline">&emsp;
                        <button class="layui-btn icon-btn" lay-filter="userTbSearch" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                    </div>
                </div>
            </form>
            <!-- 数据表格 -->
            <table id="userTable" lay-filter="userTable"></table>
        </div>
    </div>
</div>

<script type="text/html" id="adminEditDialog">
    <form id="adminEditDialog" lay-filter="adminEditDialog" class="layui-form model-form">
        <input name="id" type="hidden"/>

        <div class="layui-form-item">
            <label class="layui-form-label">基本信息:</label>
            <div>
                <a href="" target="_blank" id="zhengmian_img"><span><img src="" id="zhengmian_img2" style="width: 100px; height: 100px"></span></a>
                <a href="" target="_blank" id="fanmian_img"><span><img src="" id="fanmian_img2" style="width: 100px; height: 100px"></span></a>
                <div style="padding-left: 100px;padding-top: 10px;font-size: 18px">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>身份证号码</th>
                            <th>姓名</th>
                            <th>身份证有效期</th>
                            <th>认证状态</th>
                        </tr>
                        </thead>

                        <tbody>
                        <tr>
                            <th><span id="identitycard"></span></th>
                            <th><span id="name"></span></th>
                            <th><span id="valid_date"></span></th>
                            <th><span id="is_reals" class="css_red"></span></th>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label">营业执照:</label>
            <div>
                <a href="" id="zhizao_img2" target="_blank" id=""><span><img src="/20210418132403.jpg" style="width: 100px; height: 100px"></span></a>
                <a href="" id="yaochao_img2" target="_blank"><span><img src="" id="yaochao_img" style="width: 100px; height: 100px"></span></a>
                <a href="" id="shiping_img2" target="_blank"><span><img src="" id="shiping_img" style="width: 100px; height: 100px"></span></a>
                <div style="padding-left: 100px;padding-top: 10px;font-size: 18px">
                    <table class="layui-table">
                        <thead>
                        <tr>
                        <th>资质名称</th>
                        <th>企业名称</th>
                        <th>编号</th>
                        <th>经营范围</th>
                        <th>注册地址</th>
                        <th>注册时间</th>
                        <th>法人姓名</th>
                        <th>认证状态</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>营业执照</td>
                            <td id="company_name"></td>
                            <td id="unify_social_code"></td>
                            <td id="business_scope"></td>
                            <td id="company_addr"></td>
                            <td id="registration_date"></td>
                            <td id="legal_person"></td>
                            <td id="zhizhao_auth" class="css_red"></td>
                        <tr>
                        </tbody>
                    </table>
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>资质名称</th>
                            <th>许可证号</th>
                            <th>企业（字号）名称</th>
                            <th>负责人姓名</th>
                            <th>经营场所</th>
                            <th>许可范围</th>
                            <th>供货单位</th>
                            <th>认证状态</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>烟草证</td>
                            <td id="license_key"></td>
                            <td id="company_name2"></td>
                            <td id="principal_name"></td>
                            <td id="operation_site"></td>
                            <td id="tolerance_range"></td>
                            <td id="supplier"></td>
                            <td id="yaochao_auth" class="css_red"></td>
                        <tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label">人脸认证:</label>
            <div>

                <div style="padding-left: 100px;padding-top: 10px;font-size: 18px">
                    <span>认证状态：<span class="css_red" id="face"></span></span>
                </div>
            </div>
        </div>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label">支付结果:</label>
            <div>

                <div style="padding-left: 100px;padding-top: 10px;font-size: 18px">
                    <span>状态：<span class="css_red" id="pay"></span></span>
                </div>
            </div>
        </div>
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">审核结果:</label>-->
<!--            <div class="layui-input-block">-->
<!--                <input name="log" placeholder="" class="layui-input"-->
<!--                       lay-verType="tips"  />-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-form-item text-right">
<!--            <button class="layui-btn" lay-filter="userEditSubmit" lay-submit>保存</button>-->

            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>
<!-- 表格操作列 -->
<script type="text/html" id="userTbBar">

    
       <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">确认付款</a>
      <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="reset">审核失败</a>
</script>
<!-- 表格状态列 -->
<script type="text/html" id="userTbState">
    <input type="checkbox" lay-filter="userTbStateCk" value="{{d.id}}" lay-skin="switch"
           lay-text="正常|锁定" {{d.state==0?'checked':''}} style="display: none;"/>
    <p style="display: none;">{{d.state==0?'正常':'锁定'}}</p>
</script>

<script type="text/html" id="img">
    <img src="{{d.portraitUri}}" width="50" height="50">
</script>
<script type="text/html" id="img">
    {{d.role==1?'管理员':'商户'}}
</script>
<script type="text/html" id="is_reals">
    {{d.flag==1?'已审核':'待审核'}}
</script>
<!-- 表单弹窗 -->

<!-- js部分 -->
<script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="/static/assets/js/common.js?v=318"></script>

<script>
    layui.use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var xmSelect = layui.xmSelect;
        /* 渲染表格 */
        var insTb = table.render({
            elem: '#userTable',
            url: '/index/Admin/getCaiwu',
            page: true,
            toolbar: ['<p>',
                '<button lay-event="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                // '<button lay-event="del" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
                '</p>'].join(''),
            cellMinWidth: 100,

            cols: [[
                {type: 'checkbox'},
                {type: 'numbers'},
                {field: 'name', title: '真实姓名', sort: true},
                {field: 'phone', title: '手机号', sort: true},
                {field: 'alipay', title: '支付宝账号',},
                {field: 'money', title: '提现金额'},
                {field: 's', title: '状态',width:180},
                {
                    field: 'addtime', title: '创建时间', sort: true
                },
                {title: '操作', toolbar: '#userTbBar', align: 'center', minWidth:450}
            ]]
        });

        /* 表格搜索 */
        form.on('submit(userTbSearch)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}});
            return false;
        });

        /* 表格工具条点击事件 */
        table.on('tool(userTable)', function (obj) {
            if (obj.event === 'edit') { // 修改
                adminEditModel(obj.data);
            } else if (obj.event === 'del') { // 删除
                doDel(obj);
            } else if (obj.event === 'reset') { // 重置密码
                doFail(obj);
            } else if(obj.event === 'reUploadimg1'){ // 重新上传身份证

            }else if(obj.event === 'reUploadimg2'){ // 重新上传营业执照
                doYingyezhizhao(obj);
            }
        });
        /* 表格头工具栏点击事件 */
        table.on('toolbar(userTable)', function (obj) {
            if (obj.event === 'add') { // 添加
                showEditModel();
            } else if (obj.event === 'del') { // 删除
                var checkRows = table.checkStatus('userTable');
                if (checkRows.data.length === 0) {
                    layer.msg('请选择要删除的数据', {icon: 2});
                    return;
                }
                var ids = checkRows.data.map(function (d) {
                    return d.userId;
                });
                doDel({ids: ids});
            }
        });
        /* 显示表单弹窗 */
        function adminEditModel(mData) {

            admin.open({
                type: 1,
                area: ['1280px','800px'],
                title: (mData ? '查看' : '查看') + '用户',
                content: $('#adminEditDialog').html(),
                success: function (layero, dindexx) {
                    // 表单提交事件
                    form.on('submit(userEditSubmit)', function (data) {
                        //   data.field.roleIds = insRoleSel.getValue('valueStr');

                        var loadindexx = layer.load(2);
                        $.post('/index/Admin/editAdminuser', data.field, function (res) {  // 实际项目这里url可以是mData?'user/update':'user/add'
                            layer.close(loadindexx);
                            if (res.code === 1) {
                                layer.close(dindexx);
                                layer.msg(res.msg, {icon: 1});
                                insTb.reload({page: {curr: 1}});
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'json');
                        return false;
                    });

                    $.post('/index/Auth/getDetail', {id:mData.id}, function (res) {  // 实际项目这里url可以是mData?'user/update':'user/add'
                        if(res.data){
                            console.log(res.data)
                            $("#zhengmian_img2").attr('src', res.data.zhengmian_img);
                            $("#zhengmian_img").attr('href', res.data.zhengmian_img);
                            $("#fanmian_img").attr('href', res.data.fanmian_img);
                            $("#fanmian_img2").attr('src', res.data.fanmian_img);
                            $("#name").text(res.data.name);
                            $('#identitycard').text(res.data.identitycard);
                            $("#valid_date").text(res.data.valid_date);
                            $("#is_reals").text(res.data.is_reals);
                            $("#zhizao_img").attr('src', res.data.zhizao_img);
                            $("#zhizao_img2").attr('href', res.data.zhizao_img);
                            if(res.data.yaochao_img){
                                $("#yaochao_img").attr('src', res.data.yaochao_img);
                                $("#yaochao_img2").attr('href', res.data.zhizao_img);
                            }else{
                                $("#yaochao_img").hide();
                            }
                            if(res.data.shiping_img){
                                $("#shiping_img").attr('src', res.data.shiping_img);
                                $("#shiping_img2").attr('href', res.data.shiping_img);
                            }else{
                                $("#shiping_img").hide();
                            }
                            $("#company_name").text(res.data.company_name);
                            $("#unify_social_code").text(res.data.unify_social_code);
                            $("#business_scope").text(res.data.business_scope);
                            $("#company_addr").text(res.data.company_addr);
                            $("#legal_person").text(res.data.legal_person);
                            $("#registration_date").text(res.data.registration_date);
                            $("#zhizhao_auth").text(res.data.zhizhao_auth);

                            $("#company_name2").text(res.data.company_name2);
                            $("#license_key").text(res.data.license_key);
                            $("#principal_name").text(res.data.principal_name);
                            $("#operation_site").text(res.data.operation_site);
                            $("#tolerance_range").text(res.data.tolerance_range);
                            $("#supplier").text(res.data.supplier);
                            $("#auth_status").text(res.data.auth_status);

                            $("#face").text(res.data.face);
                            $("#pay").text(res.data.pay);
                        }
                    }, 'json');
                }
            });
        }
        /* 审核 */
        function doDel(obj) {
            layer.confirm('确定审核成功用户吗？', {
                skin: 'layui-layer-admin',
                shade: .1
            }, function (i) {
                layer.close(i);
                var loadindexx = layer.load(2);

                $.post('/index/Admin/caiwuOk', {
                    id: obj.data.id,

                }, function (res) {
                    layer.close(loadindexx);
                    if (res.code === 1) {
                        layer.msg(res.msg, {icon: 1});
                        insTb.reload({page: {curr: 1}});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'json');
            });
        }

        function doFail(obj) {
            layer.confirm('确定拒绝审核吗？', {
                skin: 'layui-layer-admin',
                shade: .1
            }, function (i) {
                layer.close(i);
                var loadindexx = layer.load(2);

                $.post('/index/Admin/caiwuFail', {
                    id: obj.data.id,

                }, function (res) {
                    layer.close(loadindexx);
                    if (res.code === 1) {
                        layer.msg(res.msg, {icon: 1});
                        insTb.reload({page: {curr: 1}});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'json');
            });
        }
        function doYingyezhizhao(obj){
            layer.confirm('确定用户重新上传营业执照吗？', {
                skin: 'layui-layer-admin',
                shade: .1
            }, function (i) {
                layer.close(i);
                var loadindexx = layer.load(2);

                $.post('/index/Auth/shenheFailYingye', {
                    id: obj.data.id,

                }, function (res) {
                    layer.close(loadindexx);
                    if (res.code === 1) {
                        layer.msg(res.msg, {icon: 1});
                        insTb.reload({page: {curr: 1}});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'json');
            });
        }

    });
</script>
</body>
</html>
